package com.tchhy.mvplibrary.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.ColorRes
import com.gyf.immersionbar.ImmersionBar
import com.tchhy.basemodule.R
import com.tchhy.basemodule.utils.SystemUtils
import com.tchhy.basemodule.widgets.dialog.ProgressLoadingDialog

/**
 * Author: wfy
 *
 * time: 2018/8/22
 *
 */
abstract class BaseFragment() : PermissionFragment() {
    protected var mInflater: LayoutInflater? = null

    var mImmersionBar: ImmersionBar? = null


    protected var mProgressLoadingDialog: ProgressLoadingDialog? = null

    abstract fun setContentLayout(): Int

    abstract fun initView()

    /**
     * 绑定生命周期
     */


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mProgressLoadingDialog = ProgressLoadingDialog.create(context!!)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(setContentLayout(), null, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initView()
    }



    @ColorRes
    open fun navigationBarColor(immersionBar: ImmersionBar): Int {
        immersionBar.navigationBarDarkIcon(true) //导航栏图标是深色，不写默认为亮色
        return R.color.common_white
    }

    override fun onPause() {
        super.onPause()
        mProgressLoadingDialog?.destroy()
    }
}